#pragma once 

#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/asio.hpp>

using boost::asio::ip::tcp;

class Communicator;

class tcp_server
{
public:
    tcp_server();

    void tcp_server::start_accept();

    /*void tcp_server::handle_accept(tcp_connection::pointer new_connection,
        const boost::system::error_code& error);*/
    void communicate();
    void receiveUnknown(std::vector<unsigned char>& buffer);
    void receiveKnown(void* buffer, unsigned int size);

    void reset();
    bool next();

    void send(std::vector<unsigned char>& data);
    void send(void* data, unsigned int size);

private:
    boost::asio::io_service io_service;
    tcp::acceptor acceptor_;
    std::vector<boost::shared_ptr<tcp::socket>> clientSockets;
    std::vector<boost::shared_ptr<tcp::socket>>::iterator socketIt;
};